#pragma once
#include <jthread.h>
#include <dsound.h>
#include "MutexBuffer.h"
#include <cstdio>

namespace ipsound {

class SoundCapture : public JThread
{
public:
	SoundCapture( MutexBuffer* buffer, LPDIRECTSOUNDCAPTUREBUFFER8 captureBuf8 );
	void SetNotifySamplesNum( const unsigned short& notifySamplesNum );
	void* Thread();
	~SoundCapture();
private:
	void GetDataFromSoundBuffer();
private:
	MutexBuffer* buffer;
	WAVEFORMATEX wfx;
	LPDIRECTSOUNDCAPTUREBUFFER8 captureBuf8;
	unsigned long soundBufOffset, soundBufSize;
	unsigned short notifySamplesNum;
	FILE* file;
};

}